public class componentContentController {
/*
upload a content document via a web form

*/
    public componentContentController(ApexPages.StandardController controller) {
        file     = new ContentVersion();
        curRef   = ApexPages.currentPage().getParameters().get('curRef');
       
    }
    
    public ContentVersion file { get; set; }
    public string curRef       { get; set; }
    public string uploadok     { get; set; }
    
    
    public PageReference go() {
        PageReference pr = new PageReference('/apex/tcloser?curRef='+curRef);
        if(curRef != Null){
            ContentWorkspace cw         = [SELECT Id, Name FROM ContentWorkspace WHERE name='Projects' limit 1];        
            file.component__c           = curRef;
            file.FirstPublishLocationId = cw.id;
        }

        try{
        insert file;
        pr.setRedirect(true); 
        }catch (Exception e) {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Unable to Upload file :'+e));
            pr = null;
        } 
        //file = null;
        return pr;
    }
    
    //Test methods
    static testMethod  void componentContentControllerTest1() {
      //start test
     //test.starttest();
       //create controller object instance to test against
       project__c proj=[select id from project__c limit 1];
       Component__c cpt = new Component__c(name='testmethod', project__c=proj.id);
        ApexPages.StandardController con = new ApexPages.StandardController(new ContentVersion());               
        componentContentController Ctlr = new componentContentController(con);
        // point the test instance to a page 
        //PageReference pageRef1 = new PageReference('/apex/applicationwiz1');
        //Test.setCurrentPage(pageRef1);
        // methods to test and vars to set
        blob b = blob.valueof('file');
        Ctlr.file.title='TESTMETHOD';
        Ctlr.file.PathOnClient='test.pdf';
        Ctlr.file.VersionData = b;
        Ctlr.go();
        Ctlr.curRef=cpt.id;
        Ctlr.go();  
       // end the test
     //test.stoptest();  
   } 

}